import os
import pandas
import requests

instr = requests.get('https://api.stg.prex.sh/api/v1/instrument/list?isTradable=true')
df = pandas.DataFrame(instr.json()['instruments'])

trading_date_str = "20210201-20210722"

cmds = []
for _, row in df.iterrows():
  base = row['symbol'].split("USD.PERP")[0]
  cmd = f"""./pyrunner python/coin/research/aqx_past_ohlc.py \
--trading_date={trading_date_str} \
--base={base} \
--volume_multiplier=5e-2 \
--price_precision={row['pricePrecision']} \
--qty_precision={row['qtyPrecision']}"""
  cmds.append(cmd)

from concurrent.futures import ProcessPoolExecutor


with open('pic/cmd.txt', 'w') as fwrt:
  print('\n'.join(cmds), file=fwrt)

jobs = []
with ProcessPoolExecutor(max_workers=32) as executor:
  for cmd in cmds:
    print(cmd)
    executor.submit(os.system, cmd)
